package com.howtoplay.data.grpctest;


import Bean.User;
import com.howtoplay.data.mapper.UserMapper;
import com.howtoplay.data.redis.RedisHandle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class HelloService {
    @Autowired
    UserMapper userMapper;

    @Resource
    RedisHandle rs;

    public String sayHello() {
        System.out.println("----------show-----------");
        return "Hello";
    }

    public String say(String words) {
        return "Hello " + words;
    }

    public User testRpc(String id) {
        System.out.println("-----testRpc-----");
        User u = userMapper.seletUserById(id);
        System.out.println(u.toString());
        rs.set(id, u);
        System.out.println("-----saveToRedis-----");
        User test = (User) rs.get(id, User.class);
        System.out.println(test.toString());
        System.out.println("-----getFromRedis-----");
        return u;
    }

}
